package com.prs.crm.domain.sys;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.prs.crm.domain.BaseEntity;
import com.prs.crm.domain.personalset.ShortcutWay;

@Entity
@Table(name="sys_menu")
public class Menu extends BaseEntity{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -5579090388339980744L;
	
	@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer id;
	
	private String text;
	
	@ManyToOne(fetch = FetchType.LAZY)
	private Module module;
	
	@ManyToOne(fetch = FetchType.LAZY)
	private Menu parent;
	
	private Integer sequence;
	
	@OneToMany(mappedBy="parent",cascade={CascadeType.MERGE,CascadeType.PERSIST,CascadeType.REMOVE})
	@OrderBy("sequence")
	@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
	private Set<Menu> childs;
	
	private Boolean shortcut;
	
	private String imgUrl;
	
	
	private String remark;

	@OneToMany(mappedBy="menu",cascade={CascadeType.ALL})
	private Set<ShortcutWay> shortcutWay;
	public Set<ShortcutWay> getShortcutWay() {
		return shortcutWay;
	}

	public void setShortcutWay(Set<ShortcutWay> shortcutWay) {
		this.shortcutWay = shortcutWay;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getId() {
		return id;
	}

	public void setText(String text) {
		this.text = text;
	}

	public String getText() {
		return text;
	}

	public void setModule(Module module) {
		this.module = module;
	}

	public Module getModule() {
		return module;
	}

	public void setParent(Menu parent) {
		this.parent = parent;
	}

	public Menu getParent() {
		return parent;
	}

	public void setChilds(Set<Menu> childs) {
		this.childs = childs;
	}

	public Set<Menu> getChilds() {
		return childs;
	}

	public void setSequence(Integer sequence) {
		this.sequence = sequence;
	}

	public Integer getSequence() {
		return sequence;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getRemark() {
		return remark;
	}

	public void setShortcut(Boolean shortcut) {
		this.shortcut = shortcut;
	}

	public Boolean getShortcut() {
		return shortcut;
	}

	public void setImgUrl(String imgUrl) {
		this.imgUrl = imgUrl;
	}

	public String getImgUrl() {
		return imgUrl;
	}
}
